<ResourceDictionary 
    x:Class="FareLiz.WPF.Styles.Default.DefaultWindowStyle"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <SolidColorBrush x:Key="TitleBarBackgroundBrush" Color="#EFEFF2" />
    <SolidColorBrush x:Key="DefaultWindowBorderBrush" Color="#007ACC" />
    <SolidColorBrush x:Key="DefaultWindowBorderBrushInactive" Color="#999999" />
    <SolidColorBrush x:Key="DefaultWindowStatusForeground" Color="#FFFFFF" />
    <SolidColorBrush x:Key="DefaultWindowStatusForegroundInactive" Color="#FFFFFF" />

    <Style x:Key="DefaultWindowStyleTitleBarButton" TargetType="{x:Type Button}">
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Border
                            x:Name="PART_border"
                            Background="Transparent"
                            />
                        <ContentPresenter />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="PART_border" Property="Background" Value="#FFF" />
                            <Setter TargetName="PART_border" Property="Opacity" Value="0.7" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="PART_border" Property="Background" Value="{StaticResource DefaultWindowBorderBrush}"/>
                            <Setter TargetName="PART_border" Property="Opacity" Value="1" />
                            <Setter Property="Foreground" Value="#FFF"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DefaultWindowStyle" TargetType="{x:Type Window}">
        <Setter Property="WindowStyle" Value="None" />
        <Setter Property="AllowsTransparency" Value="true" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="ResizeMode" Value="CanResizeWithGrip" />
        <Setter Property="WindowChrome.WindowChrome">
            <Setter.Value>
                <WindowChrome
                    NonClientFrameEdges="None"
                    GlassFrameThickness="0"
                    ResizeBorderThickness="7"
                    CaptionHeight="32"
                />
            </Setter.Value>
        </Setter>
        <EventSetter Event="Loaded" Handler="WindowLoaded" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Window}">
                    <!--
                    7 is a magic number. By default Windows fits a maximized window with Margin
                    7 7 7 5 to fill entire screen (WPF .Net 4.5). Larger numbers produce a gap
                    between maximized window and screen edges; smaller numbers show parts of
                    the window outside of the current monitor on multi-display computers.
                    -->
                    <Border
                        x:Name="PART_Container"
                        Padding="7 7 7 5"
                        >
                    <Grid
                        TextOptions.TextRenderingMode="ClearType"
                        TextOptions.TextFormattingMode="Display">
                        <Border
                            x:Name="PART_Border"
                            Width="Auto"
                            Height="Auto"
                            Background="#EFEFF2"
                            BorderBrush="{StaticResource DefaultWindowBorderBrush}"
                            BorderThickness="1"
                            Padding="0">
                            <DockPanel
                                HorizontalAlignment="Stretch"
                                Background="Transparent"
                                VerticalAlignment="Stretch"
                                >
                                <Border
                                    x:Name="TitleBar"
                                    DockPanel.Dock="Top"
                                    Background="{StaticResource TitleBarBackgroundBrush}"
                                    BorderThickness="0"
                                    >
                                    <Grid Height="32">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="36"/>
                                            <ColumnDefinition />
                                            <ColumnDefinition Width="34"/>
                                            <ColumnDefinition Width="34"/>
                                            <ColumnDefinition Width="34"/>
                                        </Grid.ColumnDefinitions>
                                        <Image
                                            x:Name="Icon"
                                            Grid.Column="0"
                                            Source="{Binding Path=Icon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" 
                                            HorizontalAlignment="Right"
                                            Margin="4,-7,0,7"
                                            Width="32"
                                            Height="32"
                                            MouseUp="IconMouseUp"
                                            MouseLeftButtonDown="IconMouseLeftButtonDown"
                                            WindowChrome.IsHitTestVisibleInChrome="True"
                                            />
                                        <TextBlock
                                            x:Name="Caption"
                                            Grid.Column="1"
                                            HorizontalAlignment="Left"
                                            VerticalAlignment="Center"
                                            FontWeight="Bold"
                                            Margin="4,0,0,0"
                                            FontFamily="Segoe UI"
                                            FontSize="12"
                                            Opacity="0.66"
                                            Text="{Binding Path=Title, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                                            />
                                        <Button
                                            x:Name="MinButton"
                                            Grid.Column="2"
                                            VerticalAlignment="Top"
                                            Width="34"
                                            Height="26"
                                            Style="{StaticResource DefaultWindowStyleTitleBarButton}"
                                            Click="MinButtonClick"
                                            WindowChrome.IsHitTestVisibleInChrome="True"
                                            >
                                            <Grid MaxHeight="9" MaxWidth="9">
                                                <Path
                                                    Stroke="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"
                                                    StrokeThickness="1"
                                                    Stretch="None"
                                                    RenderOptions.EdgeMode="Aliased"
                                                    Data="M0,8 H8 M0,7 H8 M0,6 H8"
                                                    />
                                            </Grid>
                                        </Button>
                                        <Button
                                            Grid.Column="3"
                                            x:Name="MaxButton" 
                                            VerticalAlignment="Top"
                                            Width="34"
                                            Height="26"
                                            Style="{StaticResource DefaultWindowStyleTitleBarButton}"
                                            Click="MaxButtonClick"
                                            WindowChrome.IsHitTestVisibleInChrome="True"
                                            >
                                            <Grid MaxHeight="9" MaxWidth="9">
                                                <Path
                                                    x:Name="PART_MaxButton_Path"
                                                    Stroke="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"
                                                    StrokeThickness="1"
                                                    Stretch="None"
                                                    RenderOptions.EdgeMode="Aliased"
                                                    Data="M0,0 H8 V8 H0 V0 M0,1 H8 M0,2 H8"
                                                    />
                                            </Grid>
                                        </Button>
                                        <Button
                                            Grid.Column="4"
                                            x:Name="CloseButton" 
                                            VerticalAlignment="Top"
                                            Width="34"
                                            Height="26"
                                            Style="{StaticResource DefaultWindowStyleTitleBarButton}"
                                            Click="CloseButtonClick"
                                            WindowChrome.IsHitTestVisibleInChrome="True"
                                            >
                                            <Grid MaxHeight="9" MaxWidth="9">
                                                <Path
                                                    Stroke="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"
                                                    StrokeThickness="1.5"
                                                    Stretch="None"
                                                    Data="M0,0 L8,8 M0,8 L8,0"
                                                    />
                                            </Grid>
                                        </Button>
                                    </Grid>
                                </Border>
                                <ContentPresenter />
                            </DockPanel>
                        </Border>
                    </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="WindowState" Value="Maximized">
                            <Setter TargetName="PART_MaxButton_Path" Property="Data" Value="M0,3 H5 V8 H0 V3 M0,4 H5 M3,0 H8 V5 H7 M3,1 H8"/>
                        </Trigger>
                        <Trigger Property="WindowState" Value="Normal">
                            <Setter TargetName="PART_Border" Property="Effect">
                                <Setter.Value>
                                    <DropShadowEffect
                                        Color="black"
                                        Opacity="0.5"
                                        BlurRadius="7"
                                        ShadowDepth="2"
                                        Direction="315"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsActive" Value="False">
                            <Setter TargetName="PART_Border" Property="BorderBrush" Value="{StaticResource DefaultWindowBorderBrushInactive}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Resources>
            <Style TargetType="{x:Type StatusBar}">
                <Setter Property="Foreground" Value="{StaticResource DefaultWindowStatusForeground}" />
                <Setter Property="Background" Value="{StaticResource DefaultWindowBorderBrush}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource AncestorType=Window}}" Value="False">
                        <Setter Property="Foreground" Value="{StaticResource DefaultWindowStatusForegroundInactive}" />
                        <Setter Property="Background" Value="{StaticResource DefaultWindowBorderBrushInactive}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            <Style TargetType="{x:Type ResizeGrip}">
                <Setter Property="WindowChrome.ResizeGripDirection" Value="BottomRight" />
            </Style>
        </Style.Resources>
    </Style>
</ResourceDictionary>